package com.zd.web.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zd.service.NovelService;
import com.zd.service.impl.NovelServiceImpl;

/**
 * Servlet implementation class NovelDeleteServlet
 */
@WebServlet("/NovelDeleteServlet")
public class NovelDeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	NovelService nl=new NovelServiceImpl();
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		int novelId=Integer.parseInt(request.getParameter("novelId"));
		//通过id找到这个小说的所有子章节先删子章节再删小说
		int num=nl.deleteNovel(novelId);
		if(num==1) {
			System.out.println("删除成功");
		}
		response.sendRedirect("novel.jsp");
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
